<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            margin: 0;
        }
        
        h2 {
            text-align: center;
        }
        
        ul {
            list-style: none;
            padding: 0;
            margin: 0;
            display: flex;
            justify-content: space-around;
        }
    </style>
</head>

<body>
    <div id="app">
        <zoo></zoo>
    </div>
    <script src="./js/vue.js"></script>
    <script src="./js/vue-router.js"></script>
    <script>
        // 假设有一个动物园  大门 售票处 熊猫区 老虎区 猴子区 大象区
        const Zoo = {
            template: `<div>
                    <h2>动物园</h2>
                    <ul>
                        <li>猴子区</li>
                        <li>大象区</li>
                        <li>老虎区</li>
                        <li>熊猫区</li>
                    </ul>
                    <router-view></router-view>
                </div>`
        }

        const Monkey = {
            template: `
                <div>
                    <img src="./imgs/monkey.webp" />
                </div>
            `
        }

        const Panda = {
            template: `
                <div>
                    <img src="./imgs/panda.webp" />
                </div>
            `
        }

        const Tiger = {
            template: `
                <div>
                    <img src="./imgs/tiger.webp" />
                </div>
            `
        }

        const Elephont = {
            template: `
                <div>
                    <img src="./imgs/elephont.webp" />
                </div>
            `
        }
        const routes = [{
            path: '/',
            component: Monkey
        }, {
            path: '/panda',
            component: Panda
        }, {
            path: '/tiger',
            component: Tiger
        }, {
            path: '/elephont',
            component: Elephont
        }]
        let router = new VueRouter({
            routes
        })
        Vue.component('Zoo', Zoo)
        new Vue({
            el: "#app",
            router
        })
    </script>
</body>

</html>